package com.wgo.precise.server.pdf;

import remato.domain.common.Category;
import remato.domain.common.Requirement;

import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;

public class CategoryPdfFactory extends BasicPdfFactory<Category> {
	public CategoryPdfFactory() {
		super(Category.class.getSimpleName());
	}

	public void writeConcept(Category category, Document doc, int indentation) throws DocumentException {
		String ind = getIndentation(indentation,"     ");
		int fontSize = 15 - indentation;
		Paragraph title = new Paragraph(new Chunk(ind + category.getName(), FontFactory.getFont(FontFactory.HELVETICA_BOLDOBLIQUE, fontSize, Font.NORMAL)));
		doc.add(title);
		if (null != category.getDescription()) {
			doc.add(new Paragraph(ind + category.getDescription()));
		}
		doc.add(new Paragraph("\n"));
		for (Category categoryChild : category.getCategoryChildren()) {
			getRegistry().writeDocument(doc,categoryChild,indentation+1);
		}
		for (Requirement requirement : category.getRequirements()) {
			getRegistry().writeDocument(doc,requirement,indentation+1);
		}
	}
	
	public Class<Category> getConceptClass() {
		return Category.class;
	}

}
